<?php
    require_once("condb.php");
    require_once("functions_sms_kute.php");
    
    $output = array();
    $info = isset($_GET["info"]) ? $_GET["info"] : "";
    if(!empty($info)){
        $info = urldecode(base64_decode($info));
        parse_str($info, $request);    
        
        $token = isset($request["token"]) ? cleanQuery($request["token"]) : "";
        if($token=="SmsKUteTAovieC@)!#"){
            
            $refCode = isset($request["refCode"]) ? cleanQuery($request["refCode"]) : "";
            $appId = isset($request["appId"]) ? intval($request["appId"]) : 0;            
            $combo = isset($request["combo"]) ? intval($request["combo"]) : 0;            
            $smsId = isset($request["smsId"]) ? intval($request["smsId"]) : 0;            
            $price = isset($request["price"]) ? intval($request["price"]) : 0;                        
            
            $list_price = array(
                "5000"=>"8512"
                , "10000"=>"8612"
                , "15000"=>"8712"
            );
            
            if(!empty($refCode) && !empty($appId) && !empty($price) && in_array($price, array("5000", "10000", "15000"))){
                
                $serviceCode = $list_price[$price];
                if($combo==1){
                    $mo = "SMS REG1 " . $appId . " " . $refCode;
                    
                    $output["status"] = 1;
                    $output["msg"] = "Success Request";
                } else {
                    if(!empty($smsId)){
                        $mo = "SMS REG2 " . $appId . " " . $refCode . " " . $smsId;
                        $output["status"] = 1;
                        $output["msg"] = "Success Request";
                    } else {
                        $output["status"] = 0;
                        $output["msg"] = "Invalid Request";
                    }
                        
                }
            } else {
                $output["status"] = 4;
                $output["msg"] = "Invalid Request";                        
            }
                
        } else {
            $output["status"] = 3;
            $output["msg"] = "Invalid Request";    
        }
    } else {
        $output["status"] = 2;
        $output["msg"] = "Invalid Request";
    }
            
    $output["serviceCode"] = isset($serviceCode) ? $serviceCode : "";
    $output["mo"] = isset($mo) ? $mo : "";
    echo json_encode($output);
    
    
?>
